package com.ybb.production.controller;

import com.ybb.production.dto.GarmentProductionCustomizeConfDTO;
import com.ybb.production.service.IGarmentProductionUserPayService;
import com.yubb.common.annotation.Log;
import com.yubb.common.core.controller.BaseController;
import com.yubb.common.core.domain.AjaxResult;
import com.yubb.common.core.domain.R;
import com.yubb.common.enums.BusinessType;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 用户工资发放Controller
 *
 * @author dj
 * @date 2023-09-27
 */
@RestController
@RequestMapping("/production/payConfig")
@Api(tags = "用户工资发放")
public class GarmentProductionPayConfigController extends BaseController {
    @Autowired
    private IGarmentProductionUserPayService garmentProductionUserPayService;

    @RequiresPermissions("RequiresPermissionsproduction:payConfig:add")
    @Log(title = "用户工资发放", businessType = BusinessType.INSERT)
    @ApiOperation(value = "自定义工资-保存配置项")
    @PostMapping("/addPayConfig")
    public AjaxResult addPayConfig(@RequestBody List<GarmentProductionCustomizeConfDTO> confDTOList) {
        return toAjax(garmentProductionUserPayService.addPayConfig(confDTOList));
    }

    @RequiresPermissions("RequiresPermissionsproduction:payConfig:list")
    @Log(title = "用户工资发放", businessType = BusinessType.INSERT)
    @ApiOperation(value = "自定义工资-查询配置项")
    @GetMapping("/qryPayConfig")
    public R<List<GarmentProductionCustomizeConfDTO>> qryPayConfig() {
        return R.ok(garmentProductionUserPayService.qryPayConfig());
    }
}
